package com.fly.caihong.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.fly.caihong.R;
import com.fly.caihong.base.BaseActivity;
import com.fly.caihong.model.TopicItem;
import com.fly.caihong.utils.GlideUtils;
import com.fly.caihong.utils.StatusBarUtils;

public class TopicDetailActivity extends BaseActivity {

    TopicItem mTopicItem;

    public static void launchActivity(Activity activity, TopicItem topicItem) {
        Intent intent = new Intent(activity, TopicDetailActivity.class);
        intent.putExtra("data", topicItem);
        activity.startActivity(intent);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_topic_detail;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        StatusBarUtils.setColor(this, ActivityCompat.getColor(this, R.color.theme_bg), 0);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void setStatusBarStyle() {
    }

    @Override
    protected void initViews() {
        super.initViews();
        mTopicItem = (TopicItem) getIntent().getSerializableExtra("data");
        findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        TextView tvTitle = findViewById(R.id.tv_title);
        tvTitle.setText(mTopicItem.getTopicTitle());
        TextView tvName = findViewById(R.id.tv_name);
        tvName.setText(mTopicItem.getNickName());
        TextView tvDate = findViewById(R.id.tv_date);
        tvDate.setText(mTopicItem.getDate());
        ImageView ivProfile = findViewById(R.id.iv_profile);
        GlideUtils.loadCircleAvatar(this, ivProfile, mTopicItem.getPhoto());
        TextView tvDetail = findViewById(R.id.tv_content);
        tvDetail.setText(mTopicItem.getDetail());
    }
}
